﻿using System.GunSystem;
using Model;
using QFramework;

namespace Command
{
    public class FullBulletCommand : AbstractCommand
    {
        protected override void OnExecute()
        {
            var gunSystem = this.GetSystem<IGunSystem>();
            var gunConfigModel = this.GetModel<IGunConfigModel>();

            // 填充当前枪弹夹
            gunSystem.CurrentGun.BulletCountInGun.Value =
                gunConfigModel.GetItemByName(gunSystem.CurrentGun.Name.Value).BulletMaxCount;

            // 遍历缓存的枪
            foreach (var gunInfo in gunSystem.GunInfos)
                gunInfo.BulletCountInGun.Value = gunConfigModel.GetItemByName(gunInfo.Name.Value).BulletMaxCount;
        }
    }
}